// 输入小数点后两位金额
const inputMoney = (value) => {
  value = value || ''
  return value.replace(/[^\d.]/g, '')
    .replace(/^\./g, '')
    .replace(/\.{2,}/g, '.')
    .replace('.', '$#$')
    .replace(/\./g, '')
    .replace('$#$', '.')
    .replace(/^(-)*(\d+)\.(\d\d).*$/, '$1$2.$3')
}

// 输入整数
const inputNumber = (value) => {
  value = value || 0
  return value.replace(/^(0+)|[^\d]+/g, '')
}

// 输入中文
const inputChinese = (value) => {
  value = value || ''
  return value.replace(
    /[^\u4e00-\u9fa5]/g,
    ''
  )
}
export default {
  inputMoney,
  inputNumber,
  inputChinese
}
